package com.hsp_java.list_;

import java.util.*;

public class Vector_ {
    public static void main(String[] args) {
        //1.无参构造，默认10大小

    //public Vector() {
    //        this(10);
    //    }
        //2.1添加
        //public synchronized boolean add(E e) {
        //    modCount++;
        //    ensureCapacityHelper(elementCount + 1);
        //    elementData[elementCount++] = e;
        //    return true;
        //}
        //2.2 确定是否需要扩容 , 主要条件：if (minCapacity - elementData.length > 0)

        //private void ensureCapacityHelper(int minCapacity) {
        //
        //    // overflow-conscious code
        //    if (minCapacity - elementData.length > 0)
        //        grow(minCapacity);
        //}
        //2.3 扩容
        //private void grow(int minCapacity) {
        //    // overflow-conscious code
        //    int oldCapacity = elementData.length;
        //    int newCapacity = oldCapacity + ((capacityIncrement > 0) ?
        //            capacityIncrement : oldCapacity);
        //    if (newCapacity - minCapacity < 0)
        //        newCapacity = minCapacity;
        //    if (newCapacity - MAX_ARRAY_SIZE > 0)
        //        newCapacity = hugeCapacity(minCapacity);
        //    elementData = Arrays.copyOf(elementData, newCapacity);
        //}
        Vector vector = new Vector(4);
        for (int i = 0; i < 10; i ++) {
            vector.add(i);
        }
    }
}
